<?php
class Message extends FrontAction{
	function index($pagenow,$pagesize){
		
		$lang = getlang();
		$db = $this->getDB();		
		
        /*
		require loadinc('front_pagesplit');
		
		$rownums = $db->get_assoc("select count(*) as rownums from message where lang = '".$this->lang."' ");
		$rownums = $rownums['rownums'];
		
		$pagesplit = new PageSplit();
		$pagecount = $pagesplit->getPageCount($pagesize,$rownums);
		$start = $pagesplit->getStart($pagesize,$pagenow);
		$messages = $db->query_assoc("select * from message  where lang = '".$this->lang."' limit ".$start.",".$pagesize);
		$links = "/index.php/message/index";
		$pagebar = $pagesplit->getPageBar($links,$pagenow,$pagesize,$pagecount,$this->lang);
		
		$this->data['pagebar'] = $pagebar;
		$this->data['messages']=$messages;
        */
        
		
		template('message',$this->data);	
	}
	
	function sendmessage(){
		$ckcode = P('ckcode');
		if(strtolower($ckcode) == strtolower($_SESSION['re_code'])){
			$lang = getlang();
			$db = $this->getDB();	
			$msg_title = P('msg_title');
			$msg_content = P('msg_content');
			$msg_content = addslashes($msg_content);
			
			$faceimg = P('faceimg');
			$leaver = P('leaver');
			$sex = P('sex');
			$phonenumber = P('phonenumber');
			$compname = P('compname');
			$inwhere = P('inwhere');
			$address = P('address');
			
			$db->query("insert into message (title,content,lang,createtime,faceimg,leaver,sex,phonenumber,compname,inwhere,address ) values ('$msg_title','$msg_content','".$this->lang."' ,now(),'$faceimg','$leaver','$sex','$phonenumber','$compname','$inwhere','$address')");
			
			$this->data['title']="提示";
			$this->data['url']="/index.php/message/index/1/10.html";
			$this->data['msg']="留言成功！";
			template('tip',$this->data);	
			
		}else{
			$msg = array();
			$this->data['title']="提示";
			$this->data['url']="/index.php/message/index/1/10.html";
			$this->data['msg']="验证码错误！";
			template('tip',$this->data);	
		}
	}
	
}